﻿using System;

namespace DatabaseGroup.SSIS.SourceAdapters
{
    /// <summary>
    /// Provides a constant set of strings for use within the component
    /// </summary>
    internal static class MessageStrings
    {
        // TODO: comment these so intellisense is more helpful!

        #region Private format strings

        private const string CantFindPropertyPattern = "Cannot find property: {0}";
        private const string InvalidPropertyDataTypePattern = "Invalid DataType \"{1}\" for property {0}.";
        private const string InvalidPropertyValuePattern = "Invalid value \"{1}\" for property {0}.";
        private const string PropertyStringTooLongPattern = "The string \"{1}\" is too long for property {0}.";
        private const string InvalidConnectionReferencePattern = "A single runtime connection named {0} is expected.";
        private const string DefaultColumnNamePattern = "Column {0}";
        private const string FileDoesNotExistPattern = "The following file {0} does not exist.";
        private const string FailedToAssignColumnValuePattern = "Row #{0}: Failed to assign the following value \"{1}\" to {2}.";
        private const string RowOverflowPattern = "Row #{0}: The number of parsed row columns ({1}) is greater than the number ({2}) of defined output columns.";
        private const string ParsingBufferOverflowPattern = "Row #{0}, column #{1}: Size of the parsed data exceeded maximum parsing buffer size ({2}).";
        private const string MaximumColumnNumberOverflowPattern = "Row #{0}: This row contains more columns than the maximum allowed number ({1}).";
        private const string UnsupportedDataTypePattern = "This component cannot support the {0} datatype.";

        #endregion

        #region Names and descriptions

        // TODO: consider converting to readonly properties
        public const string ComponentName = "Delimited File Source";
        public const string ComponentDescription = "An SSIS component for reading data from delimited flat files.";
        public const string OutputName = "Standard Output";
        public const string ErrorOutputName = "Error Output";
        public const string LogOutputName = "Log Output";
        public const string FileConnectionDescription = "File connection pointing to delimited file(s).";
        public const string ContactInfo = "www.databasegroup.co.uk";
        public const string IsUnicodePropDescription = "True if Unidcode file is used.";
        public const string DelayValidationPropDescription = "True if validation should be delayed until component execution.";
        public const string CodePagePropDescription = "If not Unicode the entire file is in this code page.";
        public const string TextQualifierPropDescription = "Qualifier used to enclose data containing delimiter substrings.";
        public const string HeaderRowDelimiterPropDescription = "Delimiter used for header rows.";
        public const string HeaderRowsToSkipPropDescription = "Number of header rows to skip before starting to parse data.";
        public const string DataRowsToSkipPropDescription = "Number of data rows to skip before starting to collect rows.";
        public const string ColumnNameInFirstRowPropDescription = "True if the first data row contains column names.";
        public const string ColumnDelimiterPropDescription = "Common column delimiter.";
        public const string RowDelimiterPropDescription = "Row delimiter for data rows.";
        public const string TextQualifiedPropDescription = "True if column data could be qualified.";
        public const string TreatEmptyStringsAsNullDescription = "Empty strings will be loaded into the data flow as null values.";
        public const string TrimWhitespacePropDescription = "True if field data should be trimmed of leading and trailing white space";
        public const string EscapeCharPropDescription = "Character used to escape text qualifier if used.";
        public const string IncludeErrorAuditRowsPropDescription = "True if the error output should include rows detailing each column error.";
        public const string IncludeErrorValidationMessagesPropDescription = "True if the error output should include verbose validation messages.";
        public const string IncludeErrorSourceDataPropDescription = "True if the column source data should be included in the error output.";
        public const string ErrorSourceDataTypePropDescription = "The DataType to use for column source data, must be text/string based.";
        public const string ErrorSourceDataSizePropDescription = "The maximum data length to use when a string based DataType has been specified for the Log Source DataType";
        public const string IncludeLogOutputPropDescription = "True if the log output should be added to the component.";
        public const string IncludeValidationMessagesPropDescription = "True if the log output should include verbose validation messages.";
        public const string IncludeLogSourceDataPropDescription = "True if the column source data should be included in the log output.";
        public const string LogSourceDataTypePropDescription = "The DataType to use for column source data, must be text/string based.";
        public const string LogSourceDataSizePropDescription = "The maximum data length to use when a string based DataType has been specified for the Log Source DataType";
        public const string ConfiguredFileColumnsPropDescription = "An XML block containing the configurations for all the source file columns";

        #endregion

        #region Component error message strings

        public const string CantAddInput = "Cannot add input.";
        public const string CantAddOutput = "Cannot add output.";
        public const string CantAddExternalColumns = "Cannot add external metadata columns.";
        public const string CantDeleteInput = "Cannot delete input.";
        public const string CantDeleteOutput = "Cannot delete output.";
        public const string CantDeleteExternalColumns = "Cannot delete external metadata columns.";
        public const string CantAddColumnsToErrorOutput = "Cannot add columns to the error output.";
        public const string CantAddColumnsToLogOutput = "Cannot add columns to the log output.";
        public const string CantChangeErrorOutputProperties = "Cannot change data type properties of output columns from the error output.";
        public const string CantChangeLogOutputProperties = "Cannot change data type properties of output columns from the log output.";
        public const string NotExpectedInputs = "This component should not have inputs.";
        public const string FailedToFindMainOutput = "Failed to find the main component output.";
        public const string UnexpectedNumberOfOutputs = "This component should only have one regular and one error and/or log output.";
        public const string NoOutputColumns = "There are no output columns defined for this component.";
        public const string NoErrorOutputColumns = "The error output must have its columns defined";
        public const string NoLogOutputColumns = "The log output must have its columns defined";
        public const string CannotGetFileNameFromConnection = "Could not get a file name from the assigned file connection or the connection is not selected.";
        public const string ColumnLevelErrorTruncationOperation = "Truncation error - data had to be truncated to fit column.";
        public const string ColumnLevelErrorFormatOperation = "Format error - failed to convert source data to output column type";
        public const string ColumnLevelErrorParseOperation = "CSV error - badly formatted field or malformed row data.";
        public const string OutputColumnNameAlreadyExists = "Output column name already exists - column names must be unique.";
        public const string RowLevelTruncationOperation = "Truncation - too many columns in a parsed row.";
        public const string RowLevelUnderflowOperation = "Truncation (underflow) - the number of columns provided was less than expected.";
        public const string SelectConnection = "Select Flat File connection manager from the list.";
        public const string NoCustomUI = "A custom editor for this component is not available yet. Please use the advanced editor to edit this component.";
        public const string BadParsingGraphError = "Unexpected parsing error -- internal parsing structures are not built properly.";
        public const string RowDelimiterEmpty = "Row delimiter property should have a non-empty string assigned to it.";
        public const string FailedToFindFileColumnIndex = "Failed to find the specified column index within the StandardOutputColumns custom property. Property is probably corrupt.";

        #endregion

        #region Component error formatted strings

        public static string CantFindProperty(string propertyName)
        {
            return string.Format(CantFindPropertyPattern, propertyName);
        }
        
        public static string InvalidPropertyDataType(string propertyName, object propertyValue)
        {
            return string.Format(InvalidPropertyDataTypePattern, propertyName, propertyValue);
        }
        
        public static string InvalidPropertyValue(string propertyName, object propertyValue)
        {
            return string.Format(InvalidPropertyValuePattern, propertyName, propertyValue);
        }
        
        public static string PropertyStringTooLong(string propertyName, string propertyValue)
        {
            return string.Format(PropertyStringTooLongPattern, propertyName, propertyValue);
        }
        
        public static string InvalidConnectionReference(string connectionName)
        {
            return string.Format(InvalidConnectionReferencePattern, connectionName);
        }
        
        public static string FileDoesNotExist(string fileName)
        {
            return string.Format(FileDoesNotExistPattern, fileName);
        }
        
        public static string DefaultColumnName(int columnIndex)
        {
            return string.Format(DefaultColumnNamePattern, columnIndex);
        }
       
        public static string FailedToAssignColumnValue(Int64 rowNumber, string columnValue, string columnIdentification)
        {
            return string.Format(FailedToAssignColumnValuePattern, rowNumber, columnValue, columnIdentification);
        }

        public static string RowOverflow(Int64 rowNumber, int rowColumnCount, int outputColumnCount)
        {
            return string.Format(RowOverflowPattern, rowNumber, rowColumnCount, outputColumnCount);
        }
       
        public static string ParsingBufferOverflow(Int64 rowNumber, int columnNumber, int maxBufferSize)
        {
            return string.Format(ParsingBufferOverflowPattern, rowNumber, columnNumber, maxBufferSize);
        }

        public static string MaximumColumnNumberOverflow(Int64 rowNumber, int maxNoColumns)
        {
            return string.Format(MaximumColumnNumberOverflowPattern, rowNumber, maxNoColumns);
        }

        public static string UnsupportedDataType(string dataType)
        {
            return string.Format(UnsupportedDataTypePattern, dataType);
        }

        #endregion

        #region View message strings

        public const string GeneralTabName = "General";
        public const string ColumnsTabName = "Columns";
        public const string AdvanceTabName = "Advance";
        public const string ErrorOutputTabName = "Error Output";
        public const string AuditingTabName = "Auditing";
        public const string PreviewTabName = "Preview";

        public const string NewFileConnection = "<New connection...>";

        public const string ErrorGridNameColumn = "ColumnNameColumn";
        public const string ErrorGridErrorColumn = "ErrorColumn";
        public const string ErrorGridTruncationColumn = "TruncationColumn";

        #endregion
    }
}
